package com.inpion.biz.dataStorage.test;

import com.inpion.biz.dataStorage.DataMetaInfo;
import com.inpion.biz.dataStorage.DataRecord;
import com.inpion.biz.dataStorage.DataResult;
import com.inpion.biz.dataStorage.DataServiceJob;
import com.inpion.biz.dataStorage.DataStorage;
import com.inpion.biz.dataStorage.Parameters;
import com.inpion.biz.dataStorage.FieldInfo;

public class DataStorageServiceTestCase_03 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		// storage configure init with path
		String storageConfig = "C:/Users/john/workspaces/bizBroker.0.0.0.1/BizBrokerDataStorageBusiness/config/DataStorageBusinessConfig.xml";
		DataStorage.init(storageConfig);
		
		// define job object
		DataServiceJob job = new DataServiceJob("data.storage.cassandra");
		
		// define mapping value object
		Parameters dataValue = new Parameters();				// access parameter value
		dataValue.putNoWithQuotes("COMMAND_NAME", "SELECT");
		dataValue.putNoWithQuotes("TABLE_NAME", "User");
		
		// define storage target
		job.setQueryId("cassandra.query.select.user"); 		// define query id		
		job.setParameters(dataValue);  						// define mapping value
		
		DataResult result = DataStorage.executeJob(job); 	// 
		
		if (result != null){
			
			DataMetaInfo meta = result.getDataMetaInfo();
			
			for (DataRecord record : result){
				for(String keyString : meta.keySet()){
					FieldInfo info = meta.get(keyString);
					String fieldName = info.getName();
					String fieldValue = (String) record.get(fieldName);
					
					System.out.println("[" + fieldName + "] : [" + fieldValue + "]");
				}
			}
			
		}
		
	}
		
}
